package fr.efrei.tradesys.struts.actions.admin;

import java.util.Comparator;
import java.util.List;

import org.apache.commons.beanutils.BeanComparator;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.opensymphony.xwork2.ActionSupport;

import fr.efrei.tradesys.hibernate.beans.AppUser;
import fr.efrei.tradesys.hibernate.factory.DaoFactory;

public class UsersAction extends ActionSupport
{

	/**
	 * 
	 */
	private static final long		serialVersionUID	= 1L;
	private static Log					LOGGER						= LogFactory
																										.getLog(UsersAction.class);
	private List<AppUser>				users;
	private Comparator<AppUser>	userCompLogin;

	@SuppressWarnings("unchecked")
	public String execute() throws Exception
	{
		LOGGER.info("Execution of " + this.getClass().getName());
		users = DaoFactory.getInstance().getAppUserDao().getAllEnabledAppUser();
		userCompLogin = new BeanComparator("login");
		return SUCCESS;
	}

	public List<AppUser> getUsers()
	{
		return users;
	}

	public void setUsers(List<AppUser> users)
	{
		this.users = users;
	}

	public Comparator<AppUser> getUserCompLogin()
	{
		return userCompLogin;
	}

	public void setUserCompLogin(Comparator<AppUser> userCompLogin)
	{
		this.userCompLogin = userCompLogin;
	}

}
